<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin:0;
            padding: 0;
        }
        .img_list{
            list-style: none;
            width: 300px;
            height: 400px;


        }
        img{
            width: 300px;
            height: 400px;
            vertical-align: middle;
        }

        .outer{
            width: 300px;
            margin: 50px auto;
        }

        .img_list li{
            position: absolute;
            width: inherit;
            height: inherit;
            opacity:0;
            transition: opacity 0.6s;
        }

        li.current{
            z-index: 1;
            opacity: 1;
        }

    </style>
    <script>
        /* 
            自动切换图片
        */
        document.addEventListener("DOMContentLoaded",()=>{
            setTimeout(auto=()=>{
            // 获取当前显示的图片
                const current=document.querySelector(".img_list .current")
            // 获取下一张图片
                const next_current=current.nextElementSibling||document.querySelectorAll(".img_list li:first-child")[0]

            // 切换显示状态
                current.classList.remove("current")
                next_current.classList.add("current")

                setTimeout(auto,2000)
            },2000)
        })
    </script>
</head>
<body>
    <div class="outer">
        <ul class="img_list">
            <li class="current">
                <a href="javascript:">
                    <img src="../10_DOM/images/IMG_1.JPG" alt="juilet">
                </a>
            </li>
            <li>
                <a href="javascript:">
                    <img src="../10_DOM/images/IMG_2.JPG" alt="juilet">
                </a>
            </li>
            <li>
                <a href="javascript:">
                    <img src="../10_DOM/images/IMG_3.JPG" alt="juilet">
                </a>
            </li>
            <li>
                <a href="javascript:">
                    <img src="../10_DOM/images/IMG_4.JPG" alt="juilet">
                </a>
            </li>
            <li>
                <a href="javascript:">
                    <img src="../10_DOM/images/IMG_5.JPG" alt="juilet">
                </a>
            </li>
        </ul>
    </div>
</body>
</html>